<?php

namespace plugin\admin\app\controller\banner;

use plugin\admin\app\logic\banner\BannerLogic;
use support\Request;
use support\Response;
use plugin\admin\app\controller\AuthController;
use support\exception\BusinessException;

/**
 * Banner管理 
 */
class IndexController extends AuthController
{
    
    /**
     * 浏览
     * @return Response
     */
    public function index(): Response
    {
        return view('banner/index/index');
    }

    /**
     * 查询
     * @param Request $request
     * @return Response
     * @throws BusinessException
     */
    public function select(Request $request): Response
    {
        return BannerLogic::getInstance()->select($request);
    }

    /**
     * 插入
     * @param Request $request
     * @return Response
     * @throws BusinessException
     */
    public function insert(Request $request): Response
    {
        if ($request->method() === 'POST') {
            return BannerLogic::getInstance()->insert($request);
        }
        return view('banner/index/insert');
    }

    /**
     * 更新
     * @param Request $request
     * @return Response
     * @throws BusinessException
    */
    public function update(Request $request): Response
    {
        if ($request->method() === 'POST') {
            return BannerLogic::getInstance()->update($request);
        }
        return view('banner/index/update');
    }

    /**
     * 删除
     * @param Request $request
     * @return Response
     * @throws \support\exception\BusinessException
     */
    public function delete(Request $request): Response
    {
        return BannerLogic::getInstance()->delete($request);
    }

}
